﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Script.Serialization;
using Hjp.FrameWork.Common;
using Wjtour.BLL;
using Wjtour.Common;

namespace Wjtour.Web.Admin.Ajax
{
    public class DelSceneResturantHandler : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            var sceneid = Utils.StrToInt(context.Request["sceneid"], 0);
            var restid = Utils.StrToInt(context.Request["id"], 0);

            Wjtour.BLL.sceneresturant_bll _sceneresturant_bll = new sceneresturant_bll();

            Result r = new Result();
            if (sceneid == 0)
            {
                r.Errcode = "1";
                r.Errmsg = "景点不存在";
            }
            else if (restid == 0)
            {
                r.Errcode = "2";
                r.Errmsg = "餐饮不存在";
            }
            else
            {
                bool b = _sceneresturant_bll.Delete(sceneid, restid) > 0;
                if (b)
                {
                    r.Errcode = "0";
                    r.Errmsg = "删除成功！";
                }
            }

            JavaScriptSerializer serialzier = new JavaScriptSerializer();
            string output = serialzier.Serialize(r);
            context.Response.Write(output);
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}
